<?php
/**
 * Created by PhpStorm.
 * User: caoyixian
 * Date: 2017/6/2 0002
 * Time: 下午 12:03
 */



class Site_service_relation_model extends Admin_Model{

     protected $table='site_service_relation';

    public function __construct()
    {
        parent::__construct();
        $this->load->driver('cache',array('adapter' => 'file'));

    }

     public function add($data=array()){

         if(!empty($data)){
            $this->db->insert($this->table,$data);
            return $this->db->insert_id();
         }
             return false;

     }

    public function update($data=array()){


        if(!empty($data)){

            $check = $this->db->where(['site_id'=>$data['site_id']])->get($this->table);
            if($check->row()){
                $check = $check->row();
                $result = $this->db->where(['id'=>$check->id])->update($this->table,['token'=>$data['token']]);
                return $result;
            }else{
                $this->add($data);

            }

        }
        return false;

    }















}